3. How DNS Works?

Hosts Files
They were used to translate domain names to IP addresses in earlier days of the internet but they are not used anymore.
A Hosts File is a text file containing domain names with IP addresses.

Locations:
Linux: /etc/hosts

c167aee57f15c667caede93c09744db0.png

Windows: C:\Windows\System32\drivers\etc

a23bcf98e5b0b5ac24413a1b45281fd1.png

Hosts file are used to:

  1. Block websites (like ad websites)
  2. Redirect a website (hijacking attacks)
  3. Prevent malicious attacks or for content filtering
    Tip: To prevent hijacking attacks change permission of hosts file to read only.

DNS - Behind The Scenes
Today DNS does not rely upon one file or one server, but instead upon many files across many servers around the globe. These servers are organized in a hierarchical manner.
Due to this distributed nature, the DNS system is resistant to outages (temporary suspension) of one or many of these servers.

DNS servers involved in loading a webpage:

959df0c914b6e222091090cea30e475b.png

cabfef434ad0e04ca47ed3e4e8ae56f9.png


Working

61823d741924723e496821101a6800fd.png

1c0f58f9d426ab708f74afc202ce95af.png

62f535ff363c7dee8ea8d56dce5acefd.png

bdfca94f34836311f1381338a1458222.png

3f034d5b7504d18f2b6f6827ad0fc389.png

fecdc7d5da5c77a1bc4bcfe0cdb18e06.png


3261b9f54ae44c4779642f87ea9b8cbe.png

b69f923aa8d084958e74fef7590db3d6.png


Stub Resolver
It is a resolver present in the Operating System which just forward queries.
It is a component of the DNS that is accessed by application programs when using the DNS for e.g. resolving domain names to IP addresses.
The stub resolver simply serves as an intermediary between the application requiring DNS resolution, and a recursive DNS resolver.